package com.fms.gui.existingSheets;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

public class GreenRedHighlighter extends CenteredTextRenderer implements TableCellRenderer
{
	/**
	 * 
	 */
	private static final long	serialVersionUID	= -4463669353638832031L;
	private String	toCheck;

	public GreenRedHighlighter(String _toCheck)
	{
		this.toCheck = _toCheck;
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column)
	{
		String valueString = value.toString();
		this.setText(valueString);
		if(valueString.contains(this.toCheck))
		{
			this.setBackground(Color.green);
		}
		else
		{
			this.setBackground(Color.red);
		}
		
		return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	}

}
